package com.logistics.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logistics.dto.DispatchQueryDTO;
import com.logistics.entity.DispatchRecord;
import com.logistics.vo.DispatchVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 发车记录Mapper
 */
@Mapper
public interface DispatchRecordMapper extends BaseMapper<DispatchRecord> {
    
    /**
     * 分页查询发车记录
     */
    Page<DispatchVO> selectDispatchPage(
        @Param("page") Page<DispatchVO> page,
        @Param("query") DispatchQueryDTO query,
        @Param("tenantId") Long tenantId
    );
    
    /**
     * 根据车辆ID查询最新发车记录
     */
    DispatchRecord selectLatestByVehicleId(@Param("vehicleId") Long vehicleId, @Param("tenantId") Long tenantId);
    
    /**
     * 统计各状态发车数量
     */
    Integer countByStatus(@Param("status") String status, @Param("tenantId") Long tenantId, @Param("siteId") Long siteId);
}
